﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSemanticAnalyser.SemanticTree
{
    using daSyntaxAnalyser.SyntaxTree;

    /// <summary>
    /// Тип-класс (полное объявление)
    /// </summary>
    public class FullClassTypeSemanticElement : ClassTypeSemanticElement
    {
        private ClassTypes type;
        private CommonTypeSemanticElement parentClass;
        private List<InterfaceTypeSemanticElement> parentInterfaces;
        private ClassSectionSemanticElement _private, strict_private, _protected, strict_protected, _public, _published, _automated;
        private List<ClassSectionSemanticElement> sections;
        private SectionedSemanticElement other;

        /// <summary>
        /// Тип класса (abstract/sealed)
        /// </summary>
        public ClassTypes Type { get { return type; } set { type = value; } }

        /// <summary>
        /// Родительский класс
        /// </summary>
        public CommonTypeSemanticElement ParentClass { get { return parentClass; } set { parentClass = value; } }

        /// <summary>
        /// Родительские интерфейсы
        /// </summary>
        public List<InterfaceTypeSemanticElement> ParentInterfaces { get { return parentInterfaces; } set { parentInterfaces = value; } }

        /// <summary>
        /// Секция private
        /// </summary>
        public ClassSectionSemanticElement Private { get { return _private; } set { _private = value; } }

        /// <summary>
        /// Секция strict private
        /// </summary>
        public ClassSectionSemanticElement StrictPrivate { get { return strict_private; } set { strict_private = value; } }

        /// <summary>
        /// Секция protected
        /// </summary>
        public ClassSectionSemanticElement Protected { get { return _protected; } set { _protected = value; } }

        /// <summary>
        /// Секция strict protected
        /// </summary>
        public ClassSectionSemanticElement StrictProtected { get { return strict_protected; } set { strict_protected = value; } }

        /// <summary>
        /// Секция public
        /// </summary>
        public ClassSectionSemanticElement Public { get { return _public; } set { _public = value; } }
        
        /// <summary>
        /// Секция published
        /// </summary>
        public ClassSectionSemanticElement Published { get { return _published; } set { _published = value; } }

        /// <summary>
        /// Секция automated
        /// </summary>
        public ClassSectionSemanticElement Automated { get { return _automated; } set { _automated = value; } }

        /// <summary>
        /// Список секций класса
        /// </summary>
        public List<ClassSectionSemanticElement> Sections { get { return sections; } set { sections = value; } }

        /// <summary>
        /// Остальные объявления
        /// </summary>
        public SectionedSemanticElement Other { get { return other; } set { other = value; } }

        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="Name">имя класса</param>
        /// <param name="Parent">родитель элемента семантического дерева</param>
        /// <param name="Unit">модуль, содержащий класс</param>
        /// <param name="Packed">является ли класс запакованным</param>
        /// <param name="Type">тип класса (abstract/sealed)</param>
        /// <param name="ParentClass">родительский класс</param>
        /// <param name="ParentInterfaces">родительские интерфейсы</param>
        /// <param name="Private">секция private</param>
        /// <param name="StrictPrivate">секция strict private</param>
        /// <param name="Protected">секция protected</param>
        /// <param name="StrictProtected">секция strict protected</param>
        /// <param name="Public">секция public</param>
        /// <param name="Published">секция published</param>
        /// <param name="Automated">секция automated</param>
        /// <param name="Other">остальные объявления</param>
        /// <param name="SyntaxElement">соответствующий элемент синтаксического дерева</param>
        public FullClassTypeSemanticElement(string Name, IChildSemanticElement Parent, FileSemanticElement Unit, bool Packed, ClassTypes Type, CommonTypeSemanticElement ParentClass, List<InterfaceTypeSemanticElement> ParentInterfaces, ClassSectionSemanticElement Private, ClassSectionSemanticElement StrictPrivate, ClassSectionSemanticElement Protected, ClassSectionSemanticElement StrictProtected, ClassSectionSemanticElement Public, ClassSectionSemanticElement Published, ClassSectionSemanticElement Automated, SectionedSemanticElement Other, ISyntaxTreeElement SyntaxElement)
            : base(Name, Parent, Unit, Packed, SyntaxElement)
        {
            type = Type;
            parentClass = ParentClass;
            parentInterfaces = (ParentInterfaces == null) ? new List<InterfaceTypeSemanticElement>() : ParentInterfaces;
            _private = (Private == null) ? new ClassSectionSemanticElement(this, null, null, null, null, null, null, null) : Private;
            strict_private = (StrictPrivate == null) ? new ClassSectionSemanticElement(this, null, null, null, null, null, null, null) : StrictPrivate;
            _protected = (Protected == null) ? new ClassSectionSemanticElement(this, null, null, null, null, null, null, null) : Protected;
            strict_protected = (StrictProtected == null) ? new ClassSectionSemanticElement(this, null, null, null, null, null, null, null) : StrictProtected;
            _public = (Public == null) ? new ClassSectionSemanticElement(this, null, null, null, null, null, null, null) : Public;
            _published = (Published == null) ? new ClassSectionSemanticElement(this, null, null, null, null, null, null, null) : Published;
            _automated = (Automated == null) ? new ClassSectionSemanticElement(this, null, null, null, null, null, null, null) : Automated;
            sections = new List<ClassSectionSemanticElement>();
            sections.Add(_private);
            sections.Add(strict_private);
            sections.Add(_protected);
            sections.Add(strict_protected);
            sections.Add(_public);
            sections.Add(_published);
            sections.Add(_automated);
            other = (Other == null) ? new SectionedSemanticElement(this, null, null, null, null, null, null, null) : Other;
        }
    }
}
